<?php
/*********************************************************************************
* Filename: index.php
* 
* This is the main page for the web application.  This page presents some of the
* basic features the user can expect from the game, and also provides the user
* with the required textfields needed to login to their existing team/league.
*
*
* Author: Phillip Peterson
* Date Created: 09/08/2009
**********************************************************************************/
    
//The common.php file contains 
include_once "common.php";

echo "$header_open";
echo "$css_welcome";
echo "$js_welcome";
echo "$header_close";

?>

<!-- Define the incorrect login information pop up div. -->
<div id="popupBadLogin" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Incorrect login information provided! Please try again.<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupBadLogin')">
</div>

<!-- Define the incorrect login information pop up div. -->
<div id="no_verify" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Your team has not been verified in our database.  Please verify and try again!<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('no_verify')">
</div>

<!-- Define the invalid input information pop up div. -->
<div id="popupInvaludInput" style="border:2px solid black; background-color:#C0C0C0; padding:5px; font-size:150%; text-align:center; display:none;">
	<b><u>Alert!</b></u><br><br>
	Only alphanumeric characters are allowed as input<br><br>	
	<input type="button" value="OK" onClick="Popup.hide('popupInvaludInput')">
</div>

<!--When the body loads the postLoad JS function will call all the needed onload functions-->
<body onload="postLoad();">
	<div id="wrapper">
		<div id="inner">
			<?php
				echo "$g_nav_div";
			?>
			<div id="content">
				<div class="home_intro">
	                <h2>Your Team, Your Call.</h2>
	                <p>Create or join a Fantasy Broomball league, and guide your team to the championship.  New integrated tools
	                now allow you to easily manage your team with automated scoring, stats, and player news.</p>
	            </div>				
					
				<div class="home_features">
                	<ul>
                    	<li class="feature">
								<img height="100" width="180" src="images/home/create_league.jpg" alt=""/>
								<div>
									<h6>Create a League</h6>
									<ul>
										<li>Challenge up to <b>8</b> of your friends in head-to-head Fantasy Broomball action!</li>
										<li>Customize your league experience with Live or Random Drafts</li>
										<b><a href="league_creation.php">Create a League Now!</a></b>
									</ul>
								</div>
							</li>
							<li>
								<hr />
							</li>
							<li class="feature">
								<img height="100" width="180" src="images/home/live_draft.jpg" alt=""/>
								<div>
									<h6>Live Draft Mode</h6>
									<ul>
										<li>Live-draft your players with all of your friends</li>
										<li>Alternate picking until rosters are complete</li>
										<li>Add depth and competition to your league with Live Drafts!</li>
									</ul>
								</div>
							</li>
						</ul>
					</div>
			</div>
			<div id="sidebar">
                <div class="twitter">
				    <div class="tweet">
				        <div id="user">Fantasy Broomball</div>
				        <div id="twitter_update_list"></div>
			        </div>
          			<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
                   <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/fantasybroombal.json?callback=twitterCallback2&count=1"></script>
                   <div class="follow">
                        <a href="https://twitter.com/mtubroomball">
                            <img src="images/home/twitterbird.jpg" border="0" width="129" height="130" />
                        </a>
                    </div>
               </div>
				<div id="home_login_box">
					<!-- Add the login information -->
					<table id="login_info">
						 <tr class="rowSpace">
						 	<td COLSPAN="2"><p>League Name:</p></td>
						 </tr>
						 <tr class="rowSpace">
						 	<td COLSPAN="2">
								<select class="selectElem" id="select_league">
									<option value="NULL">Select League</option>
									<?php
										//Populate the valid leagues
										$query    = "SELECT * FROM LEAGUES";
										$l_ids    = array();
										$l_names  = array();
										$results  = do_query($query, $g_db_name, $g_username);

                                        //Loop to store all of the league names and ids from the database
										while ($row = mysql_fetch_assoc($results)){
											$l_ids[]   = $row['LEAGUE_ID'];
											$l_names[] = $row['LEAGUE_NAME'];
										}
                                        //Loop to echo the value league options to the select element
										for ($i = 0; $i < sizeof($l_ids); $i++)
											echo "<option value='{$l_ids[$i]}'>{$l_names[$i]}</option>";
									?>
								</select>
							</td>
						 </tr>
						 <tr class="rowSpace">
							<td COLSPAN="2"><p>Team Name:</p></td>
						 </tr>
						 <tr class="rowSpace">
							<td COLSPAN="2"><input type="text" id="login_teamname" 
                                                   class="textfield" value="" size="22" onkeydown="keyPress(event,this);" 
                                                   onkeyup="keyUp(this);" /></td>
						</tr>
						<tr class="rowSpace">
							<td COLSPAN="2"><p>Password:</p></td>
						</tr>
						<tr>
							<td COLSPAN="2"><input type="password" id="login_password" 
                                                   class="textfield" value="" size="22" onkeydown="keyPress(event);" ></td>
						</tr>
						<tr>
							<td>
								<span class="home_checkbox"><input type="checkbox" id="login_remember"> Stay Logged In</span><br>
							    <span><a href="retrieve_password.php?mode=verify">Forgot password?</span>
							</td>
							<td class="left_align"><input class="button" 
                                type="button" value="Login" onclick='checkTeamLogin();'></td>
						</tr>
					</table>
				</div>
			</div>
			<div id="footer">
			  <?php echo "$footer"; ?>
			</div>
		</div>
	</div>
</body>
</html>
